<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <div id="app">
      <cpn></cpn>
      <cpn></cpn>
      <cpn></cpn>
    </div>

    <!-- 1.script标签，注意：类型必须是text/x-template -->
    <!-- <script type="text/x-template" id="cpn">
    <div>
      <h2>我是组件</h2>
      <p>我是内容1</p>
    </div>
  </script> -->

    <!-- 2.template标签 -->
    <template id="cpn">
      <div>
        <h2>我是组件</h2>
        <p>我是内容2</p>
      </div>
    </template>

    <script src="../js/vue.js"></script>
    <script>
      // 1.注册一个全局组件
      Vue.component('cpn', {
        template: '#cpn'
      })

      const app = new Vue({
        el: '#app',
        data: {
          message: '你好'
        }
      })
    </script>
  </body>
</html>
